#define DEBUG
#include <cstdio>
#define MAXN 50
#define MAXM 50

using namespace std;

bool change(int x, int an, int bn, int aside[][MAXN*MAXM+1], int bside[][MAXN*MAXM+1], int ato[], int bto[]) {
  static bool book[MAXN*MAXM+1];
  book[ato[x]]=true;
  for (int i=1; i<=aside[x][0]; i++) {
    if (!book[aside[x][i]]) {
      if (!bto[aside[x][i]] || change(bto[aside[x][i]], an, bn, aside, bside, ato, bto)) {
	book[ato[x]]=false;
	ato[x]=aside[x][i];
	bto[aside[x][i]]=x;
	return true;
      }
    }
  }
  book[ato[x]]=false;
  return false;
}

int main() {
#ifdef DEBUG
  freopen("4612.in", "r", stdin);
  freopen("4612.out", "w", stdout);
#endif

  static int block[2][MAXN+1][MAXM+1], aside[MAXN*MAXM+1][MAXN*MAXM+1], bside[MAXN*MAXM+1][MAXN*MAXM+1], ato[MAXN*MAXM+1], bto[MAXN*MAXM+1];
  static char map[MAXN+1][MAXM+1];
  int n, m, an=0, bn=0;
  scanf("%d %d", &n, &m);
  for (int i=1; i<=n; i++) {
    for (int j=1; j<=m; j++) {
      scanf(" %c ", &map[i][j]);
    }
  }

  for (int i=1; i<=n; i++) {
    for (int j=1; j<=m; j++) {
      if (map[i][j]=='x' || map[i][j]=='*') {
	if (map[i][j-1]=='*' || map[i][j-1]=='x') {
	  block[0][i][j] = block[0][i][j-1];
	} else {
	  block[0][i][j] = ++an;
	}
      }
    }
  }

  for (int j=1; j<=m; j++) {
    for (int i=1; i<=n; i++) {
      if (map[i][j]=='x' || map[i][j]=='*') {
	if (map[i-1][j]=='*' || map[i-1][j]=='x') {
	  block[1][i][j] = block[1][i-1][j];
	} else {
	  block[1][i][j] = ++bn;
	}

	if (map[i][j]=='*') {
	  int x=block[0][i][j], y=block[1][i][j];
	  aside[x][++aside[x][0]]=y;
	  bside[y][++bside[y][0]]=x;
	}
      }
    }
  }

  int ans=0;
  for (int i=1; i<=an; i++) {
    for (int j=1; j<=aside[i][0]; j++) {
      if (!bto[aside[i][j]] || change(bto[aside[i][j]], an, bn, aside, bside, ato, bto)) {
	bto[aside[i][j]]=i;
	ato[i]=aside[i][j];
	ans++;
	break;
      }
    }
  }
  
  printf("%d", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
